<template>
  <el-table :data="tableData" style="width: 100%">
    <!-- <el-table-column type="expand">
      <template slot-scope="props">
        <el-table :data="props.row.randoms" style="width: 100%" class="sub-table" v-if="props.row.randoms">
          <el-table-column label="序号" prop="innerSerial"> </el-table-column>
          <el-table-column label="单位名称" prop="randomUnitName"> </el-table-column>
          <el-table-column label="状态"> 
            <template slot-scope="scope">
              {{scope.row.randomBan | statusFilter}}
            </template>
          </el-table-column>
          <el-table-column label="联系人" prop="randomLinkman"> </el-table-column>
          <el-table-column label="联系电话" prop="randomPhone"> </el-table-column>
          <el-table-column label="报价" prop="bidamount"> </el-table-column>
        </el-table>
      </template>
    </el-table-column> -->
    <el-table-column label="序号" prop="serial"> </el-table-column>
    <el-table-column label="抽取时间" prop="createTime"> </el-table-column>
    <el-table-column label="中标单位" prop="randomUnitName"> </el-table-column>
  </el-table>
</template>

<script>
export default {
  props: ["tableData"],
  data() {
    return {
      pickupTime: "",
    };
  },
  filters: {
    statusFilter(val) {
      switch (val) {
        case "0":
          return "正常";
        case "1":
          return "排除";
        case "2":
          return "中签";
        case "3":
          return "中标";
        case "4":
          return "未中标";
        case "5":
          return "废除报价";
        case "6":
          return "处罚申请";
        case "7":
          return "处罚中";
        case "8":
          return "审批同意";
        case "9":
          return "审批拒绝";
        case "10":
          return "中标废除";
      }
    },
  },
  created() {
    //外层表格序号
    let index = 0;
    this.tableData.forEach(item => {
      //去除每个对象创建时间属性createTime中的秒
      const timeArr = item.createTime.split(":");
      timeArr.splice(timeArr.length-1, 1);
      const newTime = timeArr.join(":");
      item.createTime = newTime;
      item.serial = ++index;
      //内层表格序号
      let innerIndex = 0;
      item.randoms.forEach(innerItem => {
        innerItem.innerSerial = ++innerIndex;
      })
    })
  }
};
</script>

<style scoped>
::v-deep .demo-table-expand {
  font-size: 0;
}
::v-deep .demo-table-expand label {
  width: 90px;
  color: #99a9bf;
}
::v-deep .demo-table-expand .el-form-item {
  margin-right: 0;
  margin-bottom: 0;
  width: 50%;
}
::v-deep .el-table__expanded-cell[class*=cell] {
    padding: 0 50px;
}
::v-deep .el-table .cell:hover {
  white-space: normal;
}
</style>